package util;

public class SummedGaussian extends Gaussian 
{
	private double sumOfValues;
	
	@Deprecated
	public SummedGaussian(int size, double mean, double stdev, double scale, double sum)
	{
		super(size,mean,stdev);
		
		this.scaleZScores(sum/Util.arraySum(getPDF()));
		this.scaleZScores(scale);
		
		this.sumOfValues = Util.arraySum(getPDF());
	}
	
	public SummedGaussian(int size, double mean, double stdev, double sum)
	{
		super(size,mean,stdev);
		
		this.scaleZScores(sum/Util.arraySum(getPDF()));
		
		this.sumOfValues = Util.arraySum(getPDF());
	}
	
	public SummedGaussian(int size, double stdev, double sum)
	{
		super(size,stdev);
		
		this.scaleZScores(sum/Util.arraySum(getPDF()));
		
		this.sumOfValues = Util.arraySum(getPDF());
	}
	
	public SummedGaussian(double stdev, double sum)
	{
		super(stdev);
		
		this.scaleZScores(sum/Util.arraySum(getPDF()));
		
		this.sumOfValues = Util.arraySum(getPDF());
	}
	
	//TODO Add Test for SummedGaussian(double[] zscores, double sum)
	public SummedGaussian(double[] zscores, double sum)
	{
		super(zscores);
		
		this.scaleZScores(sum/Util.arraySum(getPDF()));
		
		this.sumOfValues = Util.arraySum(getPDF());
	}
	
	/**
	 * Two SummedGaussians are equal if they have the same standard dev and sum.
	 */
	public boolean equals(Object obj)
	{
		SummedGaussian gauss = (obj instanceof SummedGaussian) ? 
				((SummedGaussian) obj):(null);
				
		return (gauss.getStandardDeviation() == this.getStandardDeviation()) && 
			   (gauss.getSum() == this.getSum());
	}
	
	public double getSum()
	{
		return sumOfValues;
	}
}
